Ext.define("StatsWindow", {
	extend : 'Ext.window.Window',
	modal : true,
	width : 600,
	height : 400,
	twitterHandle:'',
	twitterDate:'',
	layout : 'fit',
	initComponent : function() {
		var chart = Ext.create('Ext.chart.Chart', {
			style : 'background:#fff',
			theme : 'Category1',
			store : Ext.create('Ext.data.Store', {
			    autoLoad: true,
			    storeId: 'storeVolume',
			    fields : [ 'day', 'volume', 'mean', 'std1below', 'std1above' ],
			    model: 'ModelName',
			    proxy: {
			        type: 'ajax',
			        url: 'http://ec2-54-221-173-96.compute-1.amazonaws.com:5000/twitter/api/alpha/',
					params: {
						handle: this.twitterHandle,
						date: this.twitterDate
					},
			        reader: {
			          type: 'json',
			          root: 'records',
			          successProperty: 'success'
			        }
			    }
			}),
			axes : [ {
				type : 'Numeric',
				position : 'left',
				fields : [ 'day', 'volume', 'mean', 'std1below', 'std1above' ],
				title : 'Tweet Volume',
				grid : true
			}, {
				type : 'Category',
				position : 'bottom',
				fields : [ 'day' ],
				title : 'Day of the Week'
			} ],
			series : [ {
				type : 'column',
				axis : 'left',
				xField : 'day',
				yField : 'volume'
			}, {
				type : 'scatter',
				axis : 'left',
				xField : 'day',
				yField : 'mean',
				markerConfig : {
					type : 'circle',
					size : 5
				}
			}, {
				type : 'line',
				axis : 'left',
				smooth : true,
				xField : 'day',
				yField : 'std1above',
				markerConfig : {
					type : 'cross',
					size : 5
				}
			}, {
				type : 'line',
				axis : 'left',
				smooth : true,
				xField : 'day',
				yField : 'std1below',
				markerConfig : {
					type : 'cross',
					size : 5
				}
			} ]
		});
		
		var panel = Ext.create('widget.panel', {
			title: this.twitterHandle,
			border : 1,
			style : {
				boderColor : '#000000',
				borderStyle : 'solid',
				borderWidth : '1px'
			},
			items: [chart]
		});
		
		this.items = [panel];

		this.callParent();
	}
});

//Ext.create("StatsWindow").show();
